package com.zxf.course.service.impl;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zxf.course.bean.Student;
import com.zxf.course.mapper.StudentMapper;
import com.zxf.course.service.StudentService;

@Service
public class StudentServiceImpl implements StudentService{
	
	@Autowired
	private StudentMapper studentMapper;
	
	@Override
	public Student selectStudentById(Integer id) {
		Student student = studentMapper.selectByPrimaryKey(id);
		
		return student;
	}

	@Override
	public boolean studentLogin(Student student) {
		
	    Student studentLogin = studentMapper.studentLogin(student);
	    
	    return studentLogin == null ? false : true;
	}

	@Override
	public List<Student> selectStudentList() {
		
		return studentMapper.selectAllStudent();
	}

	@Override
	public Boolean deleteStudent(Integer studentNo) {
		
		int deleteStatus = studentMapper.deleteByPrimaryKey(studentNo);
				
		return deleteStatus ==1 ? true : false;
	}

	@Override
	public Boolean addStudent(Student student) {
		
		int insertStatus = studentMapper.insert(student);
		
		return insertStatus == 1 ? true : false;
	}

	@Override
	public Boolean selectStudentDetail(Integer studentNo) {
		
		return null;
	}
	
	
}
